﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RATSharp.Model;
using RATSharp.Rest;
using System.Threading.Tasks;
using RATSharp.Validator;

namespace RATSharp.Action
{
    public class PickUpAction
    {
        public static void pickUpAction(RATSharp.Model.Object obj, RestService service)
        {
            Console.WriteLine("Not implemented");
            return;


            //TODO: it is not possible to make reservations over a day (midnight)
            //need to specify how this should behave so I´ll skip this feature for now :(
            DateTime since;
            DateTime to;
            do
            {
                since = DateTime.Now;
                Console.WriteLine(String.Format("Pick up since: {0: HH:mm}"), since);
                Console.WriteLine("To? (HH:mm)");
                to = MenuUtilities.GetSimpleInput(new StringInputTimeValidator("HH:mm"));
            } while (!(DateTime.Compare(to, since) > 0));


            Reservations reservations = ReservationFactory.createReservations(since, to, 1, obj, ObjectCycle.PICKED);

            Reservations responseRes;
            if (!MenuUtilities.WaitForCommTask(service.addReservation(reservations), out responseRes))
            {
                return;
            }

            if (responseRes.Count != 0)
            {
                Console.WriteLine("Following reservation is already created in your term!");
                Console.WriteLine(responseRes.First());
                Console.WriteLine("Retry? (yes/no)");
                MenuUtilities.YES_NO_CHOICE choiceRetry = MenuUtilities.GetSimpleInput(new StringInputEnumValidator<MenuUtilities.YES_NO_CHOICE>());
                if (choiceRetry != MenuUtilities.YES_NO_CHOICE.yes)
                {
                    return;
                }

            }
            else
            {
                Console.WriteLine("Reservation succesfully created!");
            }

        }


    }
}
